#!/usr/bin/env node
import { bridgeClient } from './bridge-client';
import { nativeMessagingHostInstance } from './native-messaging-host';

try {
    bridgeClient.setNativeHost(nativeMessagingHostInstance);
    nativeMessagingHostInstance.start();
} catch (error) {
    process.exit(1);
}

process.on('error', (error) => {
    process.exit(1);
});

// Handle process signals and uncaught exceptions
process.on('SIGINT', () => {
    process.exit(0);
});

process.on('SIGTERM', () => {
    process.exit(0);
});

process.on('exit', (code) => {
});

process.on('uncaughtException', (error) => {
    process.exit(1);
});

process.on('unhandledRejection', (reason) => {
    // Don't exit immediately, let the program continue running
});